package org.aplikator.client.shared.descriptor;

import com.google.gwt.user.client.ui.Widget;
import org.aplikator.client.local.widgets.FormWidget;
import org.aplikator.client.local.widgets.HasFields;
import org.aplikator.client.local.widgets.RepeatedFormWidget;
import org.aplikator.client.local.widgets.WizardFormWidget;
import org.jboss.errai.common.client.api.annotations.Portable;

@SuppressWarnings("serial")
//@Portable
public class RepeatedFormDTO extends WidgetPropertyDTOBase implements RenderWidgetAware, ContainsViewDTOReference {

    private ViewDTO view;
	private boolean selfReference;

    @SuppressWarnings("unused")
    public RepeatedFormDTO() {//TODO custom marshaller
    }

    public RepeatedFormDTO(PropertyDTO property, ViewDTO view) {
        super( property);
        this.view = view;
    }

    @Override
    public Widget getWidget(HasFields form) {
        RepeatedFormWidget repeatedForm = new RepeatedFormWidget(view, property, form, isEnabled());
        form.registerNestedCollection(repeatedForm);
        return repeatedForm;

    }

	@Override
	public ViewDTO getView() {
		return this.view;
	}

	@Override
	public void setView(ViewDTO view) {
		this.view = view;
	}

	@Override
	public boolean isSelfReferenceFlag() {
		return selfReference;
	}

	@Override
	public void setSelfReferenceFlag(boolean sref) {
		this.selfReference = sref;
	}
    
}
